{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from keras_sequential_ascii import sequential_model_to_ascii_printout"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "from keras.models import Sequential\n",
    "from keras.layers import Dense, Activation, Flatten\n",
    "from keras.layers import Conv2D, MaxPool2D, Dropout, BatchNormalization"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "           OPERATION           DATA DIMENSIONS   WEIGHTS(N)   WEIGHTS(%)\n",
      "\n",
      "               Input   #####     32   32    3\n",
      "             Flatten   ||||| -------------------         0     0.0%\n",
      "                       #####        3072\n",
      "               Dense   XXXXX -------------------     30730   100.0%\n",
      "             softmax   #####          10\n"
     ]
    }
   ],
   "source": [
    "model = Sequential()\n",
    "\n",
    "model.add(Flatten(input_shape=(32, 32, 3)))\n",
    "model.add(Dense(10))\n",
    "model.add(Activation('softmax'))\n",
    "\n",
    "sequential_model_to_ascii_printout(model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(model.layers)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30730"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.count_params()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "           OPERATION           DATA DIMENSIONS   WEIGHTS(N)   WEIGHTS(%)\n",
      "\n",
      "               Input   #####     32   32    3\n",
      "             Flatten   ||||| -------------------         0     0.0%\n",
      "                       #####        3072\n",
      "               Dense   XXXXX -------------------    393344    95.7%\n",
      "             sigmoid   #####         128\n",
      "               Dense   XXXXX -------------------     16512     4.0%\n",
      "             sigmoid   #####         128\n",
      "               Dense   XXXXX -------------------      1290     0.3%\n",
      "             softmax   #####          10\n"
     ]
    }
   ],
   "source": [
    "model = Sequential()\n",
    "\n",
    "model.add(Flatten(input_shape=(32, 32, 3)))\n",
    "model.add(Dense(128, activation='sigmoid'))\n",
    "model.add(Dense(128, activation='sigmoid'))\n",
    "model.add(Dense(10))\n",
    "model.add(Activation('softmax'))\n",
    "\n",
    "sequential_model_to_ascii_printout(model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "           OPERATION           DATA DIMENSIONS   WEIGHTS(N)   WEIGHTS(%)\n",
      "\n",
      "               Input   #####     32   32    3\n",
      "              Conv2D    \\|/  -------------------       896     2.1%\n",
      "                relu   #####     30   30   32\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####     15   15   32\n",
      "              Conv2D    \\|/  -------------------     18496    43.6%\n",
      "                relu   #####     13   13   64\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####      6    6   64\n",
      "             Flatten   ||||| -------------------         0     0.0%\n",
      "                       #####        2304\n",
      "               Dense   XXXXX -------------------     23050    54.3%\n",
      "             softmax   #####          10\n"
     ]
    }
   ],
   "source": [
    "model = Sequential()\n",
    "\n",
    "model.add(Conv2D(32, (3, 3), activation='relu',\n",
    "                 input_shape=(32, 32, 3)))\n",
    "model.add(MaxPool2D())\n",
    "\n",
    "model.add(Conv2D(64, (3, 3), activation='relu'))\n",
    "model.add(MaxPool2D())\n",
    "\n",
    "model.add(Flatten())\n",
    "model.add(Dense(10))\n",
    "model.add(Activation('softmax'))\n",
    "\n",
    "sequential_model_to_ascii_printout(model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "           OPERATION           DATA DIMENSIONS   WEIGHTS(N)   WEIGHTS(%)\n",
      "\n",
      "               Input   #####     32   32    3\n",
      "              Conv2D    \\|/  -------------------      1344     0.1%\n",
      "                relu   #####     32   32   48\n",
      "              Conv2D    \\|/  -------------------     20784     1.8%\n",
      "                relu   #####     30   30   48\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####     15   15   48\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####     15   15   48\n",
      "              Conv2D    \\|/  -------------------     41568     3.5%\n",
      "                relu   #####     15   15   96\n",
      "              Conv2D    \\|/  -------------------     83040     7.1%\n",
      "                relu   #####     13   13   96\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####      6    6   96\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####      6    6   96\n",
      "              Conv2D    \\|/  -------------------    166080    14.2%\n",
      "                relu   #####      6    6  192\n",
      "              Conv2D    \\|/  -------------------    331968    28.3%\n",
      "                relu   #####      4    4  192\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####      2    2  192\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####      2    2  192\n",
      "             Flatten   ||||| -------------------         0     0.0%\n",
      "                       #####         768\n",
      "               Dense   XXXXX -------------------    393728    33.6%\n",
      "                relu   #####         512\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####         512\n",
      "               Dense   XXXXX -------------------    131328    11.2%\n",
      "                relu   #####         256\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####         256\n",
      "               Dense   XXXXX -------------------      2570     0.2%\n",
      "             softmax   #####          10\n"
     ]
    }
   ],
   "source": [
    "model = Sequential()\n",
    "\n",
    "model.add(Conv2D(48, (3, 3), padding='same', input_shape=(32, 32, 3)))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Conv2D(48, (3, 3)))\n",
    "model.add(Activation('relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(Dropout(0.25))\n",
    "model.add(Conv2D(96, (3, 3), padding='same'))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Conv2D(96, (3, 3)))\n",
    "model.add(Activation('relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(Dropout(0.25))\n",
    "model.add(Conv2D(192, (3, 3), padding='same'))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Conv2D(192, (3, 3)))\n",
    "model.add(Activation('relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(Dropout(0.25))\n",
    "model.add(Flatten())\n",
    "model.add(Dense(512))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Dropout(0.5))\n",
    "model.add(Dense(256))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Dropout(0.5))\n",
    "model.add(Dense(10, activation='softmax'))\n",
    "\n",
    "sequential_model_to_ascii_printout(model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "           OPERATION           DATA DIMENSIONS   WEIGHTS(N)   WEIGHTS(%)\n",
      "\n",
      "               Input   #####     32   32    3\n",
      "              Conv2D    \\|/  -------------------       896     0.1%\n",
      "                relu   #####     32   32   32\n",
      "              Conv2D    \\|/  -------------------      9248     0.7%\n",
      "                relu   #####     30   30   32\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####     15   15   32\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####     15   15   32\n",
      "              Conv2D    \\|/  -------------------     18496     1.5%\n",
      "                relu   #####     15   15   64\n",
      "              Conv2D    \\|/  -------------------     36928     3.0%\n",
      "                relu   #####     13   13   64\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####      6    6   64\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####      6    6   64\n",
      "             Flatten   ||||| -------------------         0     0.0%\n",
      "                       #####        2304\n",
      "               Dense   XXXXX -------------------   1180160    94.3%\n",
      "                relu   #####         512\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####         512\n",
      "               Dense   XXXXX -------------------      5130     0.4%\n",
      "             softmax   #####          10\n"
     ]
    }
   ],
   "source": [
    "model = Sequential()\n",
    "\n",
    "model.add(Conv2D(32, (3, 3), activation='relu', padding='same',\n",
    "                 input_shape=(32, 32, 3)))\n",
    "model.add(Conv2D(32, (3, 3), activation='relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(Dropout(0.25))\n",
    "\n",
    "model.add(Conv2D(64, (3, 3), activation='relu', padding='same'))\n",
    "model.add(Conv2D(64, (3, 3), activation='relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(Dropout(0.25))\n",
    "\n",
    "model.add(Flatten())\n",
    "model.add(Dense(512, activation='relu'))\n",
    "model.add(Dropout(0.5))\n",
    "model.add(Dense(10))\n",
    "model.add(Activation('softmax'))\n",
    "\n",
    "sequential_model_to_ascii_printout(model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "           OPERATION           DATA DIMENSIONS   WEIGHTS(N)   WEIGHTS(%)\n",
      "\n",
      "               Input   #####     32   32    3\n",
      "              Conv2D    \\|/  -------------------      1344     0.1%\n",
      "                relu   #####     32   32   48\n",
      "              Conv2D    \\|/  -------------------     20784     1.8%\n",
      "                relu   #####     30   30   48\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####     15   15   48\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####     15   15   48\n",
      "              Conv2D    \\|/  -------------------     41568     3.5%\n",
      "                relu   #####     15   15   96\n",
      "              Conv2D    \\|/  -------------------     83040     7.1%\n",
      "                relu   #####     13   13   96\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####      6    6   96\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####      6    6   96\n",
      "              Conv2D    \\|/  -------------------    166080    14.2%\n",
      "                relu   #####      6    6  192\n",
      "              Conv2D    \\|/  -------------------    331968    28.3%\n",
      "                relu   #####      4    4  192\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####      2    2  192\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####      2    2  192\n",
      "             Flatten   ||||| -------------------         0     0.0%\n",
      "                       #####         768\n",
      "               Dense   XXXXX -------------------    393728    33.6%\n",
      "                relu   #####         512\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####         512\n",
      "               Dense   XXXXX -------------------    131328    11.2%\n",
      "                relu   #####         256\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####         256\n",
      "               Dense   XXXXX -------------------      2570     0.2%\n",
      "             softmax   #####          10\n"
     ]
    }
   ],
   "source": [
    "model = Sequential()\n",
    "model.add(Conv2D(48, (3, 3), padding='same', input_shape=(32, 32, 3)))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Conv2D(48, (3, 3)))\n",
    "model.add(Activation('relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(Dropout(0.25))\n",
    "model.add(Conv2D(96, (3, 3), padding='same'))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Conv2D(96, (3, 3)))\n",
    "model.add(Activation('relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(Dropout(0.25))\n",
    "model.add(Conv2D(192, (3, 3), padding='same'))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Conv2D(192, (3, 3)))\n",
    "model.add(Activation('relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(Dropout(0.25))\n",
    "model.add(Flatten())\n",
    "model.add(Dense(512))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Dropout(0.5))\n",
    "model.add(Dense(256))\n",
    "model.add(Activation('relu'))\n",
    "model.add(Dropout(0.5))\n",
    "model.add(Dense(10, activation='softmax'))\n",
    "sequential_model_to_ascii_printout(model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "           OPERATION           DATA DIMENSIONS   WEIGHTS(N)   WEIGHTS(%)\n",
      "\n",
      "               Input   #####     32   32    3\n",
      "              Conv2D    \\|/  -------------------       896     0.1%\n",
      "                relu   #####     32   32   32\n",
      "              Conv2D    \\|/  -------------------      1056     0.2%\n",
      "                relu   #####     32   32   32\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####     16   16   32\n",
      "  BatchNormalization    μ|σ  -------------------       128     0.0%\n",
      "                       #####     16   16   32\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####     16   16   32\n",
      "              Conv2D    \\|/  -------------------     18496     2.9%\n",
      "                relu   #####     16   16   64\n",
      "              Conv2D    \\|/  -------------------      4160     0.6%\n",
      "                relu   #####     16   16   64\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####      8    8   64\n",
      "  BatchNormalization    μ|σ  -------------------       256     0.0%\n",
      "                       #####      8    8   64\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####      8    8   64\n",
      "              Conv2D    \\|/  -------------------     73856    11.5%\n",
      "                relu   #####      8    8  128\n",
      "              Conv2D    \\|/  -------------------     16512     2.6%\n",
      "                relu   #####      8    8  128\n",
      "        MaxPooling2D   Y max -------------------         0     0.0%\n",
      "                       #####      4    4  128\n",
      "  BatchNormalization    μ|σ  -------------------       512     0.1%\n",
      "                       #####      4    4  128\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####      4    4  128\n",
      "             Flatten   ||||| -------------------         0     0.0%\n",
      "                       #####        2048\n",
      "               Dense   XXXXX -------------------    524544    81.6%\n",
      "                relu   #####         256\n",
      "             Dropout    | || -------------------         0     0.0%\n",
      "                       #####         256\n",
      "               Dense   XXXXX -------------------      2570     0.4%\n",
      "             softmax   #####          10\n"
     ]
    }
   ],
   "source": [
    "model = Sequential()\n",
    "\n",
    "model.add(Conv2D(32, (3, 3), activation='relu', padding='same',\n",
    "                 input_shape=(32, 32, 3)))\n",
    "model.add(Conv2D(32, (1, 1), activation='relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(BatchNormalization())\n",
    "model.add(Dropout(0.25))\n",
    "\n",
    "model.add(Conv2D(64, (3, 3), activation='relu', padding='same'))\n",
    "model.add(Conv2D(64, (1, 1), activation='relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(BatchNormalization())\n",
    "model.add(Dropout(0.25))\n",
    "\n",
    "model.add(Conv2D(128, (3, 3), activation='relu', padding='same'))\n",
    "model.add(Conv2D(128, (1, 1), activation='relu'))\n",
    "model.add(MaxPool2D())\n",
    "model.add(BatchNormalization())\n",
    "model.add(Dropout(0.25))\n",
    "\n",
    "model.add(Flatten())\n",
    "model.add(Dense(256, activation='relu'))\n",
    "model.add(Dropout(0.5))\n",
    "model.add(Dense(10))\n",
    "model.add(Activation('softmax'))\n",
    "\n",
    "sequential_model_to_ascii_printout(model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
